package com.sx.pipeline.ui.wallet.result

import android.view.View
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.sx.pipeline.BR
import com.sx.pipeline.R
import com.sx.pipeline.app.base.CYDataBindingBaseActivity
import com.sx.pipeline.app.config.IntentKey
import com.sx.pipeline.arouth.RoutePath
import com.sx.pipeline.databinding.ActRechargeResultBinding
import com.sx.pipeline.event.PayResultEvent
import com.sx.pipeline.ui.wallet.recharge.RechargeVM


/**
 * @Author: YY
 * @Date: 2022/4/5
 * @Description: 充值结果页面
 */
@Route(path = RoutePath.Wallet.RECHARGE_RESULT)
class RechargeResultActivity : CYDataBindingBaseActivity<ActRechargeResultBinding,RechargeVM>(R.layout.act_recharge_result), View.OnClickListener {

    @JvmField
    @Autowired(name = IntentKey.DATA)
    var payResultEvent: PayResultEvent? = null

    override fun initData() {
        super.initData()
        mBinding.setVariable(BR.onClick, this)
        mBinding.titleBar.leftView.setOnClickListener {
            finish()
        }
        if (payResultEvent != null) {
            if (payResultEvent!!.isSuccess) {
                mBinding.ivResult.setImageResource(R.drawable.icon_pay_success)
                mBinding.titleBar.title = getString(R.string.txt_pay_success)
                mBinding.tvName.setText(getString(R.string.txt_pay_success))
                mBinding.tvBack.setText(getString(R.string.txt_back))

            } else {
                mBinding.ivResult.setImageResource(R.drawable.icon_pay_failed)
                mBinding.titleBar.title = getString(R.string.txt_pay_failed)
                mBinding.tvName.setText(getString(R.string.txt_pay_failed))
                mBinding.tvBack.setText(getString(R.string.txt_try_again))
                mBinding.tvContent.visibility = View.VISIBLE
            }
        }

    }

    override fun onClick(v: View?) {
        when (v?.id) {
            //返回
            R.id.tv_back -> finish()
        }
    }

}